package com.fate.securecheckplatform.db;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.fate.securecheckplatform.bean.TableForbiddenPerformance;

import java.util.List;

/**
 * Author:   RandBII
 * DATE:   2020/1/10
 * Description: 违禁物品的操作
 */

@Dao
public interface ForbiddenPerformanceDao {

    @Query("SELECT COUNT(0) FROM TableForbiddenPerformance ")
    int getPerformancesCount();

    @Query("SELECT COUNT(0) FROM TableForbiddenPerformance WHERE dayTime=:day ")
    int getPerformancesCountByDay(String day);

    @Query("SELECT COUNT(0) FROM TableForbiddenPerformance")
    int getPerformancesRealCount();

    @Query("SELECT * from TableForbiddenPerformance")
    List<TableForbiddenPerformance> getForbiddenPerformances();


    @Insert
    void addOneForbiddenPerformance(TableForbiddenPerformance performance);

    @Delete
    void deleteOneForbiddenPerformance(TableForbiddenPerformance p);

    @Update
    void updateOnePerformance(TableForbiddenPerformance p);


    @Query("SELECT * from TableForbiddenPerformance   Limit :pageSize offset :offset")
    List<TableForbiddenPerformance> getPerformancesByPage(int offset, int pageSize);


    @Query("SELECT * from TableForbiddenPerformance where sfzh =:idnum and sfck!='1'")
    List<TableForbiddenPerformance> getPerformancesByIDCard(String idnum);

    /**
     * 查询未出库
     *
     * @param offset
     * @param pageSize
     * @return
     */
    @Query("SELECT * from TableForbiddenPerformance where sfck!='1' and isDelete!='1' Limit :pageSize offset :offset")
    List<TableForbiddenPerformance> getNotOutPerformances(int offset, int pageSize);


}
